﻿$(function () {
    // lay checkbox co id=chkAll
    var $chkBox = $("input:checkbox[id$=chkAll]");
    // lay mang cac checkbox co name = cid
    var $tblChkBox = $("table.list input:checkbox[name$=cid]");
    // them su kien click cho chkAll
    $chkBox.click(function () {
        $tblChkBox
        .attr('checked', $chkBox
        .is(':checked'));
    });
    // them su kien cho cac check box co name = cid
    // khi bo check thi chkAll cung tro ve trang thai uncheck
    $tblChkBox.click(
    function (e) {
        if (!$(this)[0].checked) {
            $chkBox.attr("checked", false);
        }
    });
});